Small sysctl cleanups.
authorKeir Fraser <keir@xensource.com>
Wed, 27 Jun 2007 20:27:51 +0000 (21:27 +0100)
committerKeir Fraser <keir@xensource.com>
Wed, 27 Jun 2007 20:27:51 +0000 (21:27 +0100)
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/common/schedule.c
xen/common/sysctl.c
xen/include/public/sysctl.h

index 17443a44f4c9bae521c22618e481cee27b6daf1a..7911f5f99c342cb94cd985cef44bd5485b92add7 100644 (file)
@@ -72,12 +72,8 @@ static inline void vcpu_runstate_change(
     ASSERT(v->runstate.state != new_state);
     ASSERT(spin_is_locked(&per_cpu(schedule_data,v->processor).schedule_lock));
 
-    if(unlikely((v->runstate.state_entry_time - new_entry_time) > TIME_SLOP))
-        /* Local time on this CPU has been warped */
-        v->runstate.time[v->runstate.state] = new_entry_time; 
-    else 
-        v->runstate.time[v->runstate.state] +=
-            new_entry_time - v->runstate.state_entry_time;
+    v->runstate.time[v->runstate.state] +=
+        new_entry_time - v->runstate.state_entry_time;
     v->runstate.state_entry_time = new_entry_time;
     v->runstate.state = new_state;
 }
index 28cbf9b71f37dce3e0ebab591c077155e0b421ec..16a6b5fb31b928fe86e23aeb379a07ecf58c1f72 100644 (file)
@@ -140,19 +140,20 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
     {
         uint32_t i, nr_cpus;
         uint64_t idletime;
+        struct vcpu *v;
 
-        nr_cpus = (op->u.cpuinfo.max_cpus > NR_CPUS) ? NR_CPUS :
-            op->u.cpuinfo.max_cpus;
+        nr_cpus = min_t(uint32_t, op->u.cpuinfo.max_cpus, NR_CPUS);
 
         for ( i = 0; i < nr_cpus; i++ )
         {
-            if(!idle_vcpu[i])
-                /* XXX: assumes no further CPUs after first missing one */
+            /* Assume no holes in idle-vcpu map. */
+            if ( (v = idle_vcpu[i]) == NULL )
                 break;
 
-            /* somewhat imprecise but should suffice */
-            idletime = idle_vcpu[i]->runstate.time[RUNSTATE_running] +
-                (NOW() - idle_vcpu[i]->runstate.state_entry_time);
+            idletime = v->runstate.time[RUNSTATE_running];
+            if ( v->is_running )
+                idletime += NOW() - v->runstate.state_entry_time;
+
             if ( copy_to_guest_offset(op->u.cpuinfo.buffer, i, &idletime, 1) )
             {
                 ret = -EFAULT;
@@ -163,7 +164,7 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
         op->u.cpuinfo.nr_cpus = i;
         ret = 0;
 
-        if( copy_to_guest (u_sysctl, op, 1) )
+        if ( copy_to_guest(u_sysctl, op, 1) )
             ret = -EFAULT;
     }
     break;
index be20efc4c136906ecaa6ebf0492fc6b194fefc3e..ef467d130411f33ad08e6822b6f661550c761606 100644 (file)
@@ -158,7 +158,7 @@ struct xen_sysctl_cpuinfo {
     /* IN variables. */
     uint32_t                      max_cpus;
     XEN_GUEST_HANDLE_64(uint64_t) buffer;
-    /* IN/OUT variables. */
+    /* OUT variables. */
     uint32_t                      nr_cpus;
 }; 
 typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;